package org.example.demospring.mapper;

import org.apache.ibatis.annotations.*;
import org.example.demospring.entity.User;

import java.util.List;
@Mapper

public interface UserMapper {
@Select("SELECT * FROM `user`")
List<User> findAll();

@Insert("INSERT into user(user_name,pass_word,nick_name,adress,email,phone) VALUES(#{user_name},#{pass_word},#{nick_name},#{adress},#{email},#{phone})")
    int insert(User user);

//@Update("update user set user_name=#{user_name},pass_word=#{pass_word},nick_name=#{nick_name},adress=#{adress},email=#{email},phone=#{phone},time=#{time} where id=#{id}")
    int update(User user);

@Delete("DELETE  FROM `user` WHERE id=#{id}")
    int delete(Integer id);

@Select("SELECT * FROM `user` where user_name like #{user_name} limit #{page},#{size}")
    List<User> selectPage(int page, int size, String user_name);

@Select("SELECT count(*) FROM `user` where user_name like concat('%',#{user_name},'%')")
    Integer selectTotal(String user_name);
}

